package com.example.milimili;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager2.widget.ViewPager2;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.example.milimili.util.DateUtil;
import com.example.milimili.util.WebChecker;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

public class MainActivity extends AppCompatActivity {

    public static final String FIRSTPART="https://api2.newsminer.net/svc/news/queryNewsList?size=20&startDate=2021-08-20&endDate=";
    public static final String SECONDPART="&words=";
    public static final String THIRDPART="&categories=";
    public static final String ONEPART="https://api2.newsminer.net/svc/news/queryNewsList?size=";
    public static final String TWOPART="&startDate=2021-08-20&endDate=";
    public static Boolean check=true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
            initSearchStatic();
            initFragment();
            if(check)
            {
                initGrid();
                check=false;
            }
            NewsActivity.flag=true;
    }

    private void initGrid() {
//        娱乐、军事、教育、文化、健康、财经、体育、汽车、科技、社会
        GridActivity.mUserList.add("娱乐");
        GridActivity.mUserList.add("军事");
        GridActivity.mUserList.add("教育");
        GridActivity.mUserList.add("文化");
        GridActivity.mUserList.add("健康");
        GridActivity.mUserList.add("财经");
        GridActivity.mUserList.add("体育");
        GridActivity.mUserList.add("汽车");
        GridActivity.mUserList.add("科技");
        GridActivity.mUserList.add("社会");
    }

    private void initSearchStatic() {
            SearchActivity.startDate="2021-08-20";
            SearchActivity.endDate=DateUtil.getNowDateTime();
            SearchActivity.category="";
    }

    private void initFragment() {
        FragmentManager fm=getSupportFragmentManager();
        FragmentTransaction fragmentTransaction=fm.beginTransaction();
        fragmentTransaction.replace(R.id.frameLayout,new MainFragment());
//        fragmentTransaction.replace(R.id.bottomLayout,new FragmentBottom());
        fragmentTransaction.commit();
    }

}